const mysql = require('mysql');

const pool = mysql.createConnection({
  host:'121.40.154.118',
  port:3306,
  user:'root',
  password:'letmein',
  database:'cakepro',
  connectionLimit:15
});

let query = function( sql, values ) {
  // 返回一个 Promise
  return new Promise(( resolve, reject ) => {
    pool.query(sql, values, (err, result) => {

          if ( err ) {
            reject( err )
          } else {
            resolve( result )
          }
        })
    })
}

module.exports =  query;